<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // 改变this指向的三种方式
    var name = "张三";

    var obj = {
      name: "概念布加迪",
      say: function () { }
    }
    var car = {
      name: "奔驰",
      run: function (speed, you) {
        console.log(this.name + speed + you)
        console.log(this.name + "棒")
      }
    }

    // car.run("100迈", "45油")
    // call(对象，参数1，参数2)
    car.run.call(window, "80迈", "10个馒头")
    car.run.call(obj, "80迈", "10个馒头")

    // apply(对象,[参数1，参数2])
    car.run.apply(window, ["80迈", "10个馒头"])
    car.run.apply(obj, ["80迈", "10个馒头"])
    // bind() 绑定this指向 返回函数 调用函数 
    var laoban = {
      name: "老伴"
    }
    //  绑定this指向 返回函数 
    var xinRun = car.run.bind(laoban);
    xinRun("10迈", "100退休金");
    //

  </script>
</body>

</html>